package com.dinglexiao.controller;


import com.dinglexiao.common.lang.Result;
import com.dinglexiao.entity.User;
import com.dinglexiao.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dlx
 * @since 2020-09-16
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /***
    * @description:测试一下环境是否连通
    * @param
    * @return com.dinglexiao.entity.User
    * @author dlx
    * @date 2020/9/16-21:55
    */
    @RequiresAuthentication
    @GetMapping("/index")
    public Result getUser(){
        User user = userService.getById(1);
        return Result.success(user);
    }

    @PostMapping("/save")
    public Result saveUser(@Validated @RequestBody User user){
        return Result.success(user);
    }
}
